home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / ENTRPRIS / APE / AEEXPDTR / EXPEDITR.CLS < prev    next >
Encoding:
Visual Basic class definition  |  1996-12-04  |  8.2 KB  |  226 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "Expediter"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = True
  10. Attribute VB_Description = "Returns Service Request results to clients."
  11. Option Explicit
  12. '-------------------------------------------------------------------------
  13. 'The Class is the only public class in this project.  See notes in
  14. 'modExpediter for purpose.
  15. '-------------------------------------------------------------------------
  16.  
  17. '***********************
  18. 'Public Properties
  19. '***********************
  20.  
  21. Public Property Set QueueMgrRef(ByVal oQueueMgr As APEInterfaces.QueueDelegator)
  22. Attribute QueueMgrRef.VB_Description = "Sets the QueueDelegator object that the Expediter uses to receive Service Request results from the AEQueueMgr."
  23.     '-------------------------------------------------------------------------
  24.     'Purpose:   Called by the the QueueMgr to pass a reference of itself to
  25.     '           the Expediter
  26.     'In:        [oQueueMgr]
  27.     '               A valid reference to a QueueMgr class object
  28.     'Effects:   [goQueueDelegator]
  29.     '               Sets the global object variable equal to the passed reference
  30.     '-------------------------------------------------------------------------
  31.     Set goQueueDelegator = oQueueMgr
  32.     
  33. End Property
  34.  
  35. Public Property Let Show(ByVal bShow As Boolean)
  36. Attribute Show.VB_Description = "Determines whether the Expediter shows a form."
  37.     '-------------------------------------------------------------------------
  38.     'Purpose:   Show property determines whether or not a form
  39.     '           is displayed while expediter is loaded
  40.     'Effects:   [gbShow] becomes value of parameter
  41.     '           If parameter is true frmExpediter is show, else form
  42.     '           is hidden.  Form is never unloaded because the timer is needed
  43.     '-------------------------------------------------------------------------
  44.     
  45.     If Not gbShow = bShow Then
  46.         gbShow = bShow
  47.         If bShow = True Then
  48.             frmExpediter.Show
  49.             'Update U/I values
  50.             With frmExpediter
  51.                 .lblBacklog.Caption = glBacklog
  52.                 .lblPeak = glPeakBacklog
  53.                 .lblBacklog.Refresh
  54.                 .lblPeak.Refresh
  55.             End With
  56.         Else
  57.             'Never Unload form because it has a timer
  58.             frmExpediter.Hide
  59.         End If
  60.     End If
  61.     
  62. End Property
  63.  
  64. Public Property Get Show() As Boolean
  65.     Show = gbShow
  66. End Property
  67.  
  68. Public Property Let Log(ByVal bLog As Boolean)
  69. Attribute Log.VB_Description = " Determines if the Expediter logs its events and errors to the AELogger.Logger object."
  70.     '-------------------------------------------------------------------------
  71.     'Purpose:   If log is true create logger class object and log Services
  72.     'Effects:   [gbLog] becomes value of parameter
  73.     '           [goLogger] is set to a new AELogger.Logger object if parameter
  74.     '                      is true.  If false goLogger is destroyed
  75.     '-------------------------------------------------------------------------
  76.     
  77.     If Not gbLog = bLog Then
  78.         gbLog = bLog
  79.         If bLog = True Then
  80.             Set goLogger = New AELogger.Logger
  81.         Else
  82.             Set goLogger = Nothing
  83.         End If
  84.      End If
  85. End Property
  86.  
  87. Public Property Get Log() As Boolean
  88.     Log = gbLog
  89. End Property
  90.  
  91. '*****************
  92. 'Public Methods
  93. '*****************
  94.  
  95. Public Sub SetProperties(ByVal bShow As Boolean, Optional ByVal bLog As Variant)
  96. Attribute SetProperties.VB_Description = "Sets properties in one method call."
  97.     '-------------------------------------------------------------------------
  98.     'Purpose:   To set the Logger properties in one method call
  99.     'Effects:   Sets the following properties to parameter values
  100.     '           Show, Log
  101.     '-------------------------------------------------------------------------
  102.     With Me
  103.         .Show = bShow
  104.         If Not IsMissing(bLog) Then .Log = bLog
  105.     End With
  106. End Sub
  107.  
  108. Public Sub StopTest()
  109. Attribute StopTest.VB_Description = "Causes the Expediter to stop processing Service Request results and to empty its queue."
  110.     '-------------------------------------------------------------------------
  111.     'Purpose:   Call this to halt the Expediter and have its
  112.     '           collection of Service requests and their
  113.     '           respective CallBack objects removed
  114.     'Effects:
  115.     '           DestroyReferences may be called
  116.     '       [gbStopTest]
  117.     '           becomes true
  118.     '-------------------------------------------------------------------------
  119.     
  120.     gbStopTest = True
  121.     If Not gbBusy Then DestroyReferences
  122. End Sub
  123.  
  124. Public Sub StartTest()
  125. Attribute StartTest.VB_Description = "Prepares the Expediter to process Service Request results after StopTest has been called."
  126.     '-------------------------------------------------------------------------
  127.     'Purpose:   Call this to allow processing of Services
  128.     '           after calling StopTest
  129.     'Effects:
  130.     '           Reinitialize values on U/I
  131.     '       [gcCallback]
  132.     '           Make sure it is a zero count collection
  133.     '       [gbStopTest]
  134.     '           becomes false
  135.     '       [frmExpediter.tmrExpediter]
  136.     '           becomes enabled
  137.     '-------------------------------------------------------------------------
  138.     glPeakBacklog = 0
  139.     glBacklog = 0
  140.     glTotalCallBacks = 0
  141.     With frmExpediter
  142.         .lblPeak = 0
  143.         .lblCount = 0
  144.         .lblBacklog = 0
  145.         .lblPeak.Refresh
  146.         .lblCount.Refresh
  147.         .lblBacklog.Refresh
  148.     End With
  149.     gbStopTest = False
  150.     DisplayStatus ""
  151.     Set gcCallBack = Nothing
  152.     Set gcCallBack = New Collection
  153.     If Not goQueueDelegator Is Nothing Then frmExpediter.tmrExpediter.Interval = giTIMER_INTERVAL
  154. End Sub
  155.  
  156. Public Function GetEventObject() As EventReturn
  157. Attribute GetEventObject.VB_Description = "Returns a new EventReturn object."
  158.     Set GetEventObject = New EventReturn
  159. End Function
  160.  
  161. '********************
  162. 'Private Procedures
  163. '********************
  164.  
  165. Private Sub Class_Initialize()
  166.     '-------------------------------------------------------------------------
  167.     'Purpose:   If this is the first instance, initialize the whole application
  168.     '           Set defaults and create needed objects
  169.     'Effects:
  170.     '       [glInstances]
  171.     '           iterated once to count instances
  172.     '-------------------------------------------------------------------------
  173.     'Count how many times this class is instanced
  174.     'to react to the first instance or the release
  175.     'of the last instance.
  176.     On Error GoTo Class_InitializeError
  177.     glInstances = glInstances + 1
  178.     If glInstances = 1 Then
  179.         App.OleServerBusyRaiseError = True
  180.         App.OleServerBusyTimeout = 10000
  181.         gbUnloading = False
  182.         'Set default property values
  183.         'Create Logger class object if gbLog is true
  184.         If gbLog Then Set goLogger = New AELogger.Logger
  185.         gbShow = gbSHOW_FORM_DEFAULT
  186.         gbLog = gbLOG_DEFAULT
  187.         'Create gcCallBack collection
  188.         Set gcCallBack = New Collection
  189.         'Load frmExpediter because it has a timer
  190.         Load frmExpediter
  191.         'Only show the form if gbShow is true
  192.         If gbShow Then frmExpediter.Show
  193.     End If
  194.     Exit Sub
  195. Class_InitializeError:
  196.     LogError Err, 0
  197.     Resume Next
  198. End Sub
  199.  
  200. Private Sub Class_Terminate()
  201.     '-------------------------------------------------------------------------
  202.     'Purpose:   If this is the last termination unload form and destroy objects
  203.     'Effects:
  204.     '       [glInstances]
  205.     '           decrease once to count instances
  206.     '-------------------------------------------------------------------------
  207.     'Count how many times this class is instanced
  208.     'so subtract one every terminate event
  209.     'If the last terminate event is occuring
  210.     'make sure forms are unloaded and objects
  211.     'are released
  212.     On Error GoTo Class_TerminateError
  213.     glInstances = glInstances - 1
  214.     If glInstances = 0 Then
  215.         gbUnloading = True
  216.         StopTest
  217.     End If
  218.     Exit Sub
  219. Class_TerminateError:
  220.     LogError Err, 0
  221.     Resume Next
  222. End Sub
  223.  
  224.  
  225.  
  226.